#include<iostream>
#include<vector>
using namespace std;

int main()
{
    int n, m;
    string p, q;
    cin >> n >> p >> m >> q;

    vector<int> next(n, 0);
    for(int i = 1, j = 0; i < n; i++) {
        while(j > 0 && p[i] != p[j]) j = next[j - 1];
        if(p[i] == p[j]) j++;
        next[i] = j;
    }

    int j = 0;
    for(int i = 0; i < m; i++) {
        while(j > 0 && p[j] != q[i]) j = next[j - 1];
        if(p[j] == q[i]) j++;
        if(j == n) {
            cout << i - n + 1 << " ";
            j = next[j - 1]; // 继续匹配下一个
        }
    }
    cout << endl;

    return 0;
}
